﻿using System;

namespace QBZ.Evaluation.Models
{
    public class ResponseModel
    {
        public ResponseStatusModel status { get; set; }
        public Object result { get; set; }
        public ResponseModel()
        {
            status = new ResponseStatusModel(ErrReason.UnknownError);
        }

        public ResponseModel(ErrReason errReason)
        {
            status = new ResponseStatusModel(errReason);
        }

        public ResponseModel(int errReason)
        {
            if (Enum.IsDefined(typeof(ErrReason), errReason))
            {
                status = new ResponseStatusModel((ErrReason)errReason);
            }
            else
            {
                status = new ResponseStatusModel(ErrReason.UnknownError);
            }
        }

        public ResponseModel(ResponseStatusModel status1)
        {
            this.status = status1;
        }
    }

    public class ResponseStatusModel
    {
        public ErrReason code { get; set; }
        public string msg { get; set; }
        public ResponseStatusModel()
        {
            code = ErrReason.UnknownError;
            msg = code.ToString();
        }
        public ResponseStatusModel(ErrReason errReason)
        {
            code = errReason;
            msg = errReason.ToString();
        }
    }

    public enum ErrReason
    {
        Ok = 0,
        UnknownError = 1,
        WrongDataFormat = 2,
        UserNamePasswordsDoNotMatch = 3,
        OAuthFailld = 4,
        OAuthGetInfoFaild = 5,
        OnlyAllowEmptyAccountToMerge = 6, 
        UserNotExist = 7,
        BadRequest = 400,
        Unauthorized = 401,
        AccessDenied = 403,
        NotFound = 404,
        ServerError = 500,
        BadGetWay = 502,
    }
}
